/** 扑克牌 值与标识的对应关系 */
export const PokerCardVal = {
  1: "3",
  2: "4",
  3: "5",
  4: "6",
  5: "7",
  6: "8",
  7: "9",
  8: "10",
  9: "J",
  10: "Q",
  11: "K",
  12: "A",
  13: "2",
  14: "M",
  15: "S",
};

/** 花色 */
export enum PokerType {
  /** 小丑 */
  joker,
  /** 黑桃 */
  spade,
  /** 红桃 */
  heart,
  /** 梅花 */
  club,
  /** 方块 */
  diamond,
}

/** 扑克的创建参数 */
export interface PokerCardOpt {
  /** 扑克的值 */
  val: keyof typeof PokerCardVal;
  /** 牌的花色 */
  type: PokerType;
}

/** 一张扑克牌 */
export class PokerCard {
  /** 牌的值 */
  public value: keyof typeof PokerCardVal;
  /** 花色 */
  public type: PokerType;
  /** 牌显示的名称 */
  public get label() {
    return PokerCardVal[this.value];
  }
  /** 代表的字母 */
  public get letter() {
    return String.fromCharCode(64 + this.value);
  }

  constructor({ val, type }: PokerCardOpt) {
    this.value = val;
    this.type = type;
  }

  /**
   * 字母重新转回扑克牌的值
   * @param letter 字母
   * @returns 
   */
  public static letter2value(letter:string){
    return letter.charCodeAt(0) - 64
  }

  public toString() {}
}
